{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Plotting Approximate Stability Regions"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as pt\n",
        "\n",
        "from cmath import exp, pi"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def approximate_stability_region_1d(step_function, make_k, prec=1e-5):\n",
        "    def is_stable(k):\n",
        "        y = 1\n",
        "        for i in range(20):\n",
        "            if abs(y) > 2:\n",
        "                return False\n",
        "            y = step_function(y, i, 1, lambda t, y: k*y)\n",
        "        return True\n",
        "    \n",
        "    def refine(stable, unstable):\n",
        "        assert is_stable(make_k(stable))\n",
        "        assert not is_stable(make_k(unstable))\n",
        "        while abs(stable-unstable) > prec:\n",
        "            mid = (stable+unstable)/2\n",
        "            if is_stable(make_k(mid)):\n",
        "                stable = mid\n",
        "            else:\n",
        "                unstable = mid\n",
        "        else:\n",
        "            return stable\n",
        "\n",
        "    mag = 1\n",
        "    if is_stable(make_k(mag)):\n",
        "        mag *= 2\n",
        "        while is_stable(make_k(mag)):\n",
        "            mag *= 2\n",
        "\n",
        "            if mag > 2**8:\n",
        "                return mag\n",
        "        return refine(mag/2, mag)\n",
        "    else:\n",
        "        mag /= 2\n",
        "        while not is_stable(make_k(mag)):\n",
        "            mag /= 2\n",
        "\n",
        "            if mag < prec:\n",
        "                return mag\n",
        "        return refine(mag, mag*2)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def plot_stability_region(center, stepper):\n",
        "    def make_k(mag):\n",
        "        return center+mag*exp(1j*angle)\n",
        "\n",
        "    stab_boundary = []\n",
        "    for angle in np.linspace(0, 2*np.pi, 100):\n",
        "        stable_mag = approximate_stability_region_1d(stepper, make_k)\n",
        "        stab_boundary.append(make_k(stable_mag))\n",
        "        \n",
        "    stab_boundary = np.array(stab_boundary)\n",
        "    pt.grid()\n",
        "    pt.axis(\"equal\")\n",
        "    pt.plot(stab_boundary.real, stab_boundary.imag)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xu8VXP+x/HXRyGXxolSQyoi3YZSmibGHJJC5DJM+TE1\n/DAzv2HCuIzpNzFyH5coP4Qmg4kxxnXcSntCVNIh6YqT0oWQcUsX398f33N05OxzVu3Ld+213s/H\nYz/OXvus9vr0afXZa3/Wd32XOecQEZFk2iJ0ACIiUjgq8iIiCaYiLyKSYCryIiIJpiIvIpJgKvIi\nIgmWlyJvZnea2Qozez3L739iZqvM7NWqx7B8bFdEROrWME/vMxa4Gbi7jnUmO+eOztP2REQkgrwc\nyTvnXgA+rmc1y8e2REQkumL25Hua2Uwze8LMOhZxuyIiqZWvdk19ZgCtnXNfmNnhwMNAuyJtW0Qk\ntYpS5J1zn9V4/qSZ3WJmOzrnPtp4XTPTZDoiIpvIOVdrSzyf7RojS9/dzJrXeN4DsNoKfDXnXM6P\n4cOH5+V90vBQrpQn5am0c1WXvBzJm9l9QDmwk5m9CwwHtvL12t0O/NTMfgWsBb4EfpaP7dalsrKy\n0JtIDOUqGuUpGuUpumLkKi9F3jl3Uj2/Hw2Mzse2REQkusRe8TpkyJDQIZQM5Soa5Ska5Sm6YuTK\n6uvnFJuZubjFJCISZ2aGK8KJ11jJZDKhQygZylU0ylM0ylN0xchVYou8iIioXSMiUvJS2a4REZEE\nF3n1BaNTrqJRnqJRnqJTT15ERHKinryISIlTT15EJKUSW+TVF4xOuYpGeYpGeYpOPXkREcmJevIi\nIiVOPXkRkZRKbJFXXzA65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apkuievJntWWNxADAnVCxxZmb9gAuAo51z\nX4WOp4SoL/9t04E9zay1mW0FDAQeDRxTnBlF2IcSPU7ezB4E2uFPuC4CfumcWxY2qvgxswXAVsCH\nVS+97Jz7dcCQYsvMjgFuBpriz/NUOOcODxtVfFQdMIzEH0De6Zy7KnBIsWRm9wHlwE7ACmC4c25s\nQbaV5CIvIpJ2iW7XiIiknYq8iEiCqciLiCSYiryISIKpyIuIJJiKvIhIgqnIi4gkmIq8iEiC/T/C\n1aMREJkloQAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f14406e5278>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "def fw_euler_step(y, t, h, f):\n",
        "    return y + h * f(t, y)\n",
        "\n",
        "plot_stability_region(-1, fw_euler_step)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcFNW1wPHfGXZQGcWABJXxQRSIy7gRVGImigooIS5x\nj46JazSaGH0u8UWMJi5PnxrjEp9LXEIMT9EIboAyKlERFxaRTXQAw6YiioDIDOf9cXukwR7omaqu\n23X7fD+f/tDVXU6d44Uz1adv3RJVxRhjTPjKfAdgjDEmGVbwjTGmRFjBN8aYEmEF3xhjSoQVfGOM\nKRFW8I0xpkRELvgisr2IvCAi74rINBE5v5H9/iQic0RksohURj2uMcaYpmkZw8+oAy5U1ckisgXw\npoiMUdWZDTuIyCCgh6p+R0S+B9wF9Ivh2MYYY/IU+QxfVRer6uTM8y+AGUC3jXYbCjyY2Wci0FFE\nukQ9tjHGmPzF2sMXkQqgEpi40VvdgAVZ2//mm78UjDHGFFBsBT/TznkUuCBzpr/B2zn+E1vTwRhj\nEhRHDx8Ra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hG76XK5i5WU9UrgCsy/dJfAsOSj7L5YrgYr6jlk19A7MLIAIjIFsCjwAUbdRE24KXgq+oh\nuV4XkV2BCmCKuNP77YE3RaSvqi5NMMRIGssvh7/j+vjDChdN/DaXX+ZivMHAQclEFK8mjF8IPgR2\nzNreHljoKRbTDCLSElfsH1LVf25q36Jq6ajqO8DXs1ZE5ANgL1UNpv8mIj1V9b3M5lBczy0YeV6M\nF4rUffrMoUkXRqaYEMZ45XIf8K6q3rq5HYv1S9sGSniDdJ2ITBWRybiZSBf4DihmOS/GC4WI/FhE\nFgD9gNEikmvBwNQohQsjRWQ48Aqws4jMF5HTfMcUFxE5ADgJOCgz1futzElX7v3twitjjCkNxX6G\nb4wxJiZW8I0xpkRYwTfGmBJhBd8YY0qEFXxjjCkRVvCNMaZEWME3xpgSYQXfGGNKxP8DxGqSfXtB\nnI4AAAAASUVORK5CYII=\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f144042ee10>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "def heun_step(y, t, h, f):\n",
        "    yp1_fw_euler =  y + h * f(t, y)\n",
        "    return y + 0.5*h*(f(t, y) + f(t+h, yp1_fw_euler))\n",
        "\n",
        "plot_stability_region(-1, heun_step)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAEACAYAAAB8nvebAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYFdWZx/HvAQRFxR5UkBGhRzGjAoqKGgFNQzAorvFR\nE+NEOpHEjEkMD7jjRBITE02IuBE1EVFcyBgziriBiYUKKgK2IAFEDYsLiwooKkt3n/nj0KSD9/Z2\n69apOvf3eZ5+2upu6r6+nPtS/dapc4y1FhERyZZWvgMQEZHmU/EWEckgFW8RkQxS8RYRySAVbxGR\nDF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jTCygHXjPGGFwrYK4x5mhr7ZoEQ0yFfHmqY4wZBgwFBiUTUWa8A3Srd9wV\neM9TLKlnjGmDK9yTrLWP+o4nLpoq6JEx5h/AEdbadb5jSRtjzInAWOB4a+2HvuNJE2NMa2AJ8FXg\nfWA2cK61NqE9fLLFGHMv8IG1dqTvWOKknrdflhJumzTiFmA3YLoxZp4xZrzvgNLCWlsD/Ag3I2ch\nMFmFOzdjTH/gPGDQtn0H5m27MMg8XXmLiGSQrrxFRDJIxVtEJINUvEVEMkjFW0Qkg1S8RUQySMVb\nRCSDVLxFRDJIxVtEJIP+H0uU6Ejf+wSoAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f14403aa320>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "def rk4_step(y, t, h, f):\n",
        "    k1 = f(t, y)\n",
        "    k2 = f(t+h/2, y + h/2*k1)\n",
        "    k3 = f(t+h/2, y + h/2*k2)\n",
        "    k4 = f(t+h, y + h*k3)\n",
        "    return y + h/6*(k1 + 2*k2 + 2*k3 + k4)\n",
        "\n",
        "plot_stability_region(-1, rk4_step)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.1+"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}